package com.niiwoo.civet.scheduler.trigger;

import com.alibaba.dubbo.config.annotation.Reference;
import com.niiwoo.civet.user.service.dataflow.DataBackFlowRetryDubboService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.concurrent.CompletableFuture;


/**
 * 数据回流重试定时任务
 *
 * @author wuke
 * @date 2018/01/11 17:00
 */
@Slf4j
@Component
public class DataBackFlowRetryJobTrigger {

    @Reference(version = "1.0.0")
    private DataBackFlowRetryDubboService DataBackFlowRetryDubboService;

    @Scheduled(cron = "${databackflow.databackflow_retry_info}")
    public void dataBackFlowRetryForJob() {
        log.info("dataBackFlowRetryForJob start");
        try {
            CompletableFuture.runAsync(() -> DataBackFlowRetryDubboService.dataBackFlowRetry());
        } catch (Exception e) {
            log.error("dataBackFlowRetryForJob异常",e);
        }
        log.info("dataBackFlowRetryForJob end");
    }

}